package com.sss.hloster02;

import java.util.*;

public class TestDriver {//泛型

	public static void main(String[] args) {
		test03();
	}

	private static void test03() {
		Map<String, Object> map = new TreeMap<String, Object>();
		map.put("zhangsan", 30);
		map.put("lisi", 20);
		map.put("lisi", "40岁");
		map.put("wangwu", 18);
		System.out.println("增强型for循环遍历取出HashMap集合的Key元素集合进行遍历：");
		Set<String> setKeys = map.keySet();
		for (String key : setKeys) {
			Object val = map.get(key);
			System.out.println(key + "---" + val);
		}
		System.out.println("使用迭代器循环遍历取出HashMap集合中的Key元素集合进行遍历：");
		Iterator<String> it = setKeys.iterator();
		while (it.hasNext()) {
			String key = it.next();
			Object val = map.get(key);
			System.out.println(key + "---" + val);

		}
	}
}
